import { Given, When, Then } from '@cucumber/cucumber';
import { Browser, Page, expect } from "@playwright/test";
import { pageFixture } from "../hooks/pageFixture";

Given('the user logins to the website', async function () {
    await pageFixture.page.goto('https://petstore.octoperf.com/actions/Account.action?signonForm=');
    await pageFixture.page.locator("input[name='username']").fill("admin");
    await pageFixture.page.locator("input[name='password']").fill("admin");
    await pageFixture.page.locator("(//input[@type='submit'])[2]").click();
    await pageFixture.page.waitForSelector("#WelcomeContent", {state: "visible", TIMEOUT:8000});
});


When('user click shopping cart button', async function () {
    await pageFixture.page.locator("img[name='img_cart']").click();
});



Then('the shopping cart should be empty', async function () {
    let info = await pageFixture.page.locator("//b[normalize-space(text())='Your cart is empty.']").textContent();
    expect(info).toBe('Your cart is empty.');
});